package com.wxxymakers.grademark.utils;

import io.github.biezhi.ome.OhMyEmail;
import io.github.biezhi.ome.SendMailException;
import lombok.extern.slf4j.Slf4j;
import org.springframework.scheduling.annotation.Async;
import org.springframework.stereotype.Component;

/**
 * @AUTHOR soft
 * @DATE 2018/12/21 20:59
 * @DESCRIBE 邮件工具
 */
@Slf4j
@Component
public class EmailUtils {

    public EmailUtils() {
        OhMyEmail.config(OhMyEmail.SMTP_QQ(false),
                "172748315@qq.com", "snvahqatyikqbiej");
    }

    @Async
    public void send(String title, String to, String content) {
        try {
            OhMyEmail.subject(title)
                    .from("皖西学院等级评定系统")
                    .to(to)
                    .html(content)
                    .send();
        } catch (SendMailException e) {
            log.error("邮件发送失败！{}", e.getMessage());
        }
    }
}
